package com.gobang.demo.mapper;

import com.gobang.demo.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("Select * from user where username=#{username}")
    public User selectByUsername(String username);

    @Insert("insert into user(username,password) values(#{userName},#{password})")
    public int insert(String userName,String password);

    @Update("update user set score = score + 300,totalCount = totalCount + 1,winCount = winCount + 1 where userId = #{userId}")
    public void bonusPoint(int userId);

    @Update("update user set score = score - 300,totalCount = totalCount + 1 where userId = #{userId}")
    public void markDown(int userId);
}
